package com.androidjam.runningacoruna;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;

public class TrackDetailsActivity extends Activity {

	private Button startButton;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.trackdetails_activity);        
        
        Track t = null;
        if(RunningMapActivity.staticItem!=null)
         t = RunningMapActivity.staticItem.getTrack();
        		
        
        ListView listView = (ListView) findViewById(R.id.listView1);
		String[] values = new String[] {"",""};		
				
		int hours = t.getEstimatedTime() / (1000*60*60);
			int	minutes = (t.getEstimatedTime() % (1000*60*60)) / (1000*60);
				int seconds = ((t.getEstimatedTime() % (1000*60*60)) % (1000*60)) / 1000;
				int milisecs = ((t.getEstimatedTime() % (1000*60*60)) % (1000*60) % 1000);
		
						
		if(t!=null){
			values = new String[] { getResources().getString(R.string.track_name_tag)+": "+t.getTitle()
					,getResources().getString(R.string.track_type_tag)+": "+Track.getTypeString(t.getType())
					,getResources().getString(R.string.track_description_tag)+": "+t.getDescription()
					,getResources().getString(R.string.track_distance_tag)+": "+t.getDistance()+ " kms"
					,getResources().getString(R.string.track_elevation_tag)+": "+t.getElevation()+" %"
					,getResources().getString(R.string.track_calories_tag)+": "+t.getCalories()+" kcal"
					,getResources().getString(R.string.track_heart_rythm_tag)+": "+t.getHeart_rythm()+" "+getResources().getString(R.string.heart_rythm_units)
					,getResources().getString(R.string.track_stimatedTime_tag)+"(hh:mm:ss:ms): "+hours+":"+minutes+":"+seconds+":"+milisecs};
		}
		else{ values = new String[] { "VACIO"};
		}
		
		// First paramenter - Context
		// Second parameter - Layout for the row
		// Third parameter - ID of the TextView to which the data is written
		// Forth - the Array of data
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, android.R.id.text1, values);

		// Assign adapter to ListView
		listView.setAdapter(adapter);
        
        
    }
/*
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
    */
}